package com.tedu.charging.service.device.controller;

import java.util.List;


import com.tedu.charging.common.pojo.web.ServerResult;
import com.tedu.charging.service.device.pojo.vo.ChargingStationVO;
import com.tedu.charging.service.device.pojo.vo.NearbyChargingStationVO;
import com.tedu.charging.service.device.service.IChargingStationService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 充电站Controller
 * 
 * @author ruoyi
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/charge/station")
@CrossOrigin
@Slf4j
public class ChargingStationController
{
    @Autowired
    private IChargingStationService chargingStationService;

    /**
     * 查找用户附近充电桩
     * @param longitude 经度
     * @param latitude  纬度
     * @param radius    范围
     * @return
     */
    @GetMapping("/selectNearbyStation")
    public ServerResult<List<NearbyChargingStationVO>> selectNearbyStation(double longitude, double latitude, double radius){
        List<NearbyChargingStationVO> voList = chargingStationService.selectNearbyStation(longitude, latitude, radius);

        return ServerResult.success(voList);
    }

    /**
     * 获取充电站详细信息
     */

    @GetMapping(value = "/{id}")
    public ServerResult<ChargingStationVO> getInfo(@PathVariable("id") Integer id)
    {
        ChargingStationVO chargingStationVO = chargingStationService.selectChargingStationById(id);
        return ServerResult.success(chargingStationVO);
    }

}
